home *** CD-ROM | disk | FTP | other *** search
File List | 1989-09-10 | 30.3 KB | 966 lines |
- ' *****************************************************************************
- ' * WORD PUZZLE DESIGNER *
- ' * BY EARL C. TOMAN *
- ' * Copyright 1989 Antic Publishing Company *
- ' *****************************************************************************
- ' * VARIABLES: *
- ' * No_cols% = Number of columns in puzzle *
- ' * No_rows% = Number of rows in puzzle *
- ' * No_cells% = Number of cells in puzzle *
- ' * No_directions% = Number of directions for words *
- ' * Mx% = Mouse x position
- ' * My% = Mouse y position
- ' * Mb% = Mouse buttons status
- ' * Txtptr% = Number of menu selection chosen by mouse click *
- ' * Colour% = Fill colour in graphics title screen
- ' * Crosshatch$ = "#" *
- ' * Quotes$ = Double quote *
- ' * Space$ = Single space *
- ' * No_words% = Number of words in puzzle *
- ' * Old_no_word% = Save area for No_words% during Edit_words routine *
- ' * Word_index% = Calculated index into Words$() based on mouse posn *
- ' * Temp$ = Temporary text variable *
- ' * Rez% = Screen resolution *
- ' * Pass = Pass counter when filling puzzle *
- ' * Cell_ptr = Pointer to current position in cell list *
- ' * Words_available = Number of words available when filling puzzle *
- ' * Durection = Direction to try when filling puzzle *
- ' * Sf! = Swap flag used in sort (True if swap occurred) *
- ' * Pattern! = Flag to indicate if pattern exists *
- ' * Words! = Flag to indicate if word list exists *
- ' * Wayflag! = Flag to indicate if directions initialized *
- ' * Build! = Flag to indicate if puzzle build needed *
- ' * Delete! = Flag indicating word deletion during Edit_words *
- ' * ARRAYS: *
- ' * Grid$(r,c) = Puzzle grid *
- ' * Ri(n) = Row increments that produce path directions *
- ' * Ci(n) = Col increments that produce path directions *
- ' * Sequence(n) = Sequence in which cells are examined *
- ' * Words$(n) = The word list *
- ' * Store_words$(n) = Holding array used to recopy Word$(n) *
- ' * Words_used(n) = Keeps track of words used & where they are in puzzle*
- ' * Words_unused(n) = Lists unused words in descending order of length *
- ' *****************************************************************************
- ' **** Check Screen Resolution ****
- Rez%=Xbios(4) ! Hires = 2 Medres = 1 Lores = 0
- If Rez%=0
- Cls
- M$="YOUR SCREEN IS IN LOW RES. | PLEASE CHANGE TO| MEDIUM RESOLUTION"
- Alert 0,M$,1,"OK",Button%
- End ! Abort program to allow rez change
- Endif
- ' **** Draw Graphic Title Screen *********************************************
- Gosub Draw_title
- ' **** Program Inializations **************************************************
- Max_words%=80 ! Maximum of 80 words per puzzle
- Dim Words$(Max_words%) ! Array for word list
- Dim Store_words$(Max_words%) ! Temporary holding area for Word$(n)
- Dim Strip$(60) ! Menu bar choices
- Space$=" "
- Crosshatch$="#"
- Quotes$=Chr$(34)
- Pattern!=False ! False when no pattern exists
- Words!=False ! False when word list not initialized
- Build!=False ! False when build needed
- No_directions%=8 ! Default to 8 directions
- Temp$="" ! String corresponding to text of menu choice
- Gosub Init_directions ! Initialize direction arrays
- Wayflag!=True ! Set flag to indicate directions initialized
- Cls
- Fullw 1 ! Opens window and set to full size of screen
- Gosub Main ! Paint main menu bar, and initialize choices
- Menu 28,1 ! Show beginning default of 8 directions
- ' ******************* Beginning of Main Loop **********************************
- Do ! Loop allows menu items to be selected by mouse *
- Txtptr%=0 ! *
- On Menu ! *
- Txtptr%=Menu(0) ! Menu(0) is a number indicating menu choice *
- If Txtptr%<>0 ! *
- Gosub Main_menu_actions ! *
- Gosub Main ! Repaint main menu bar, and init choices *
- Endif ! *
- Loop ! *
- ' ********************** End of Main Loop *************************************
- '
- ' **** PROCEDURE MAIN - Paint main menu bar, and init choices *****************
- Procedure Main
- Titlew 1," Word Puzzle Designer "
- Restore Main_menu_bar_data
- Gosub Build_menu_bar
- If Words!<>True Or Pattern!<>True ! Disable Build Puzzle & Reprint Puzzle
- Menu 31,2 ! Choices if no word list or pattern
- Menu 32,2
- Endif
- If Pattern!<>True ! Disable all pattern choices except Create & Load Pattern
- For I%=12 To 15 ! if no pattern has yet been initialized
- Menu I%,2
- Next I%
- Else
- Menu 11,2 ! Disable only Create Pattern choice if a pattern exists
- Endif
- If Words!<>True ! Disable all Wordlist choices except New Words and
- For I%=20 To 23 ! Load Words if no word list yet exists
- Menu I%,2
- Next I%
- Endif
- If Build!<>True
- Menu 32,2
- Endif
- If No_directions%=8 ! Check mark in front of 8 directions
- Menu 27,0
- Menu 28,1
- Else ! Check mark in front of 4 directions
- Menu 27,1
- Menu 28,0
- Endif
- Return
- ' ******* PROCEDURE MAIN_MENU_ACTIONS ******************************************
- ' Purpose: Initiate appropriate subroutine as per main menu choice *
- '
- Procedure Main_menu_actions
- Menu Off ! De-highlight chosen selection
- Menu Kill
- Temp$=Strip$(Txtptr%)
- If Temp$=" Quit "
- Closew 1
- End ! End the program
- Endif
- If Temp$=" Word Puzzle Designer "
- Gosub Title
- Endif
- If Temp$=" Create "
- Gosub Create_pattern
- Endif
- If Temp$=" Print "
- Gosub Print_pattern
- Endif
- If Temp$=" Edit "
- Gosub Chg_pattern
- Endif
- If Temp$=" New "
- Gosub New_pattern
- Endif
- If Temp$=" Save "
- Gosub Save_pattern
- Endif
- If Temp$=" Load "
- Gosub Load_pattern
- Endif
- If Temp$=" New Wordlist "
- Gosub Init_words
- Endif
- If Temp$=" Print Wordlist "
- Gosub Print_wordlist
- Endif
- If Temp$=" Add Words "
- Gosub Add_words
- Endif
- If Temp$=" Edit Wordlist "
- Gosub Edit_words
- Endif
- If Temp$=" Save Wordlist "
- Gosub Save_wordlist
- Endif
- If Temp$=" Load Wordlist "
- Gosub Load_wordlist
- Endif
- If Temp$=" Four Directions " Or Temp$=" Eight Directions "
- Gosub Init_directions
- Endif
- If Temp$=" Build Puzzle "
- Gosub Build_puzzle
- Endif
- If Temp$=" Reprint Puzzle "
- Gosub Print_puzzle
- Endif
- Return
- ' ******* PROCEDURE TITLE ************************************************
- Procedure Title
- Cls
- Sound 1,14,3,4,4
- Sound 1,0,0,0,4
- Sound 1,14,3,4,4
- Sound 1,0,0,0,4
- Sound 1,14,3,4,4
- Sound 1,0,0,0,4
- Sound 1,14,11,3,16
- Sound 1,0,0,0
- M$="WORD PUZZLE DESIGNER v1.1| A GFA Basic Program| By Earl Toman| "+Chr$(189)+" 1989 Antic Publishing"
- Alert 0,M$,1,"Return",Button%
- Return
- ' ******* PROCEDURE CREATE_PATTERN (of puzzle) *****************************
- Procedure Create_pattern
- Cls
- Repeat
- Input "How many rows in the pattern (1-22)";No_rows%
- Until No_rows%>=1 And No_rows%<=22
- Repeat
- Input "How many columns in the pattern (1-40)";No_cols%
- Until No_cols%>=1 And No_cols%<=40
- No_cells%=No_rows%*No_cols%
- Dim Grid$(No_rows%,No_cols%),Sequence(No_cells%) ! Dimension grid
- Pattern!=True ! Set flag to indicate a pattern exists
- Gosub Erasegrid
- Gosub Chg_pattern
- Return
- ' ******* PROCEDURE ERASEGRID (of puzzle) ********************************
- Procedure Erasegrid
- Print "Erasing puzzle grid"
- For J%=1 To No_rows%
- For K%=1 To No_cols%
- If Grid$(J%,K%)<>Space$
- Grid$(J%,K%)=Crosshatch$
- Endif
- Next K%
- Next J%
- Cls
- Return
- ' ******* PROCEDURE INIT_WORDS *******************************************
- Procedure Init_words
- Print At(1,1);"Enter Words. Press RETURN on a new line to end the word list."
- Print " (Maximum word length allowed is 15 characters)"
- No_words%=1
- Do
- Print "Word ";No_words%;": ";
- Form Input 15,Words$(No_words%)
- Exit If Words$(No_words%)=""
- Words$(No_words%)=Upper$(Words$(No_words%))
- Inc No_words%
- If No_words%>Max_words%
- Print
- Print "***** WORD LIST FULL *****"
- Pause 100
- Endif
- Exit If No_words%>Max_words%
- Loop
- Dec No_words%
- Erase Words_used()
- Erase Words_unused()
- Dim Words_used(No_words%),Words_unused(No_words%)
- If (No_words%>=1)
- Words!=True
- Endif
- Clearw 1 ! Clear the window and then return
- Return
- ' ******* PROCEDURE PRINT_WORDLIST *****************************************
- Procedure Print_wordlist
- Gosub Select_device
- Clearw 1
- Print #1,Tab(10);"*** WORD LIST CONTENTS ***"
- Print
- Gosub Print_word_list
- If Dv=1
- Print
- Print " < TO CONTINUE: CLICK MOUSE BUTTON, OR PRESS ANY KEY >"
- Repeat
- Button%=Mousek
- Key$=Inkey$
- Until (Button%=1 Or Button%=2) Or Key$<>""
- Endif
- Gosub Close_device
- Clearw 1
- Return
- ' ******* PROCEDURE ADD_WORDS **************************************************
- Procedure Add_words
- If No_words%>=Max_words%
- Print
- Print "***** WORD LIST FULL *****"
- Pause 100
- Else
- Print At(1,1);"Enter Words. Press RETURN on a new line to end the word list."
- Print " (Maximum word length allowed is 15 characters)"
- Inc No_words%
- Do
- Print "Word ";No_words%;": ";
- Form Input 15,Words$(No_words%)
- Exit If Words$(No_words%)=""
- Words$(No_words%)=Upper$(Words$(No_words%))
- Inc No_words%
- If No_words%>Max_words%
- Print
- Print "***** WORD LIST FULL *****"
- Pause 100
- Endif
- Exit If No_words%>Max_words%
- Loop
- Dec No_words%
- Build!=False ! Force puzzle rebuild if words added
- Erase Words_used()
- Erase Words_unused()
- Dim Words_used(No_words%),Words_unused(No_words%)
- Endif
- Clearw 1 ! Clear the window and then return
- Return
- ' ******* PROCEDURE EDIT_WORDS ************************************************
- Procedure Edit_words
- Titlew 1," Edit Wordlist "
- Restore Ed_menu_bar_data
- Gosub Build_menu_bar
- For I%=1 To Max_words%
- Store_words$(I%)=""
- Next I%
- Delete!=False ! No words deleted
- Old_no_words%=No_words% ! Save starting contents of No_words%
- Display_words:
- Row%=1 ! Display word list
- Col%=1
- I%=1
- While (I%<=Old_no_words%)
- Print At(Col%,Row%);Words$(I%)
- Col%=Col%+16
- If (Col%>65)
- Print
- Row%=Row%+1
- Col%=1
- Endif
- I%=I%+1
- Wend
- If Rez%=1 ! If medium rez
- Color 2 ! Text color is red
- Deftext 2,0,0,6
- Box 0,152,639,199
- Box 0,152,152,199
- Line 8,170,128,170
- Else ! High rez
- Box 0,304,639,399
- Box 0,304,152,399
- Line 8,340,128,340
- Endif
- Print At(6,20);"EDIT WORD";
- Print At(22,20);"** POINT TO THE DESIRED WORD WITH THE MOUSE POINTER **";
- Print At(22,21);"** PRESS LEFT MOUSE BUTTON TO EDIT THE WORD, OR **";
- Print At(22,22);"** RIGHT MOUSE BUTTON TO DELETE/UNDELETE THE WORD **";
- If Rez%=1 ! Back to black text
- Color 1 ! and lines
- Deftext 1,0,0,6
- Endif
- Mb%=0
- Do
- On Menu
- Temp$=Strip$(Menu(0))
- Exit If Temp$=" Back to Main Menu "
- If Temp$=" Word Puzzle Designer "
- Menu Off
- Gosub Title
- Goto Display_words
- Endif
- Mouse Mx%,My%,Mb%
- If (Mb%<>0)
- Row%=(My%/(Rez%*8))+1
- If (Mx%<125) ! Calculate offset of selected word in Word$()
- Col%=1
- Word_index%=1+((Row%-1)*5)
- Else
- If (Mx%<253)
- Col%=17
- Word_index%=2+((Row%-1)*5)
- Else
- If (Mx%<381)
- Col%=33
- Word_index%=3+((Row%-1)*5)
- Else
- If (Mx%<509)
- Col%=49
- Word_index%=4+((Row%-1)*5)
- Else
- Col%=65
- Word_index%=5+((Row%-1)*5)
- Endif
- Endif
- Endif
- Endif
- If (Word_index%<=Old_no_words%)
- If (Mb%=1) ! Left mouse button pressed
- Hidem ! Hide mouse pointer
- Print At(2,21); ! Edit word
- Form Input 15 As Words$(Word_index%)
- Words$(Word_index%)=Upper$(Words$(Word_index%))
- Print At(2,21);" ";
- Print At(Col%,Row%);" "; ! Blank display field
- Print At(Col%,Row%);Words$(Word_index%); ! Display edited word
- Showm ! Display mouse pointer
- Else ! Right mouse button pressed
- If (Mb%=2)
- If (Words$(Word_index%)<>"")
- Store_words$(Word_index%)=Words$(Word_index%)
- Words$(Word_index%)="" ! Delete word
- Print At(Col%,Row%);" "; ! Blank displayed word
- Dec No_words% ! Decrement word count
- If No_words%=0
- Words!=False
- For I%=20 To 23 ! Disable wordlist choices
- Menu I%,2
- Next I%
- Endif
- Pause 6 ! Eliminate button bounce
- Delete!=True ! Set delete! flag
- Else
- Words$(Word_index%)=Store_words$(Word_index%)
- Inc No_words%
- Print At(Col%,Row%);Words$(Word_index%);
- Pause 6
- Endif
- Endif
- Endif
- Endif
- Endif
- Loop
- If (Delete!=True) ! If one or more words have been deleted,
- J%=1 ! copy word array (now containing holes)
- For I%=1 To Old_no_words% ! to temporary array. Then recopy back,
- If (Words$(I%)<>"") ! weeding out the empty word slots
- Store_words$(J%)=Words$(I%)
- Inc J%
- Endif
- Next I%
- For I%=1 To No_words%
- Words$(I%)=Store_words$(I%)
- Next I%
- Endif
- Clearw 1
- Return
- ' ******* PROCEDURE SAVE_WORDLIST **********************************************
- Procedure Save_wordlist
- Cls
- Fileselect Dir$(0)+"\*.WDS","",Temp$
- If Temp$<>""
- If Right$(Temp$,4)<>".WDS"
- Temp$=Temp$+".WDS"
- Endif
- Open "O",#1,Temp$
- Write #1,No_words%
- For I%=1 To No_words%
- Write #1,Words$(I%)
- Next I%
- Print At(20,6);Temp$;" has been saved on disk"
- Close #1
- Pause 100
- Cls
- Endif
- Return
- ' ******* PROCEDURE LOAD_WORDLIST *****************************************
- Procedure Load_wordlist
- Cls
- Fileselect Dir$(0)+"\*.WDS","",Temp$
- If Temp$<>""
- Open "I",#1,Temp$
- Input #1,No_words%
- Erase Words_used()
- Erase Words_unused()
- Dim Words_used(No_words%),Words_unused(No_words%)
- For I%=1 To No_words%
- Input #1,Words$(I%)
- Next I%
- Words!=True
- Close #1
- Print At(20,6);Temp$;" wordlist loaded"
- Pause 100
- Cls
- Endif
- Return
- ' ******* PROCEDURE INIT_DIRECTIONS *************************************
- Procedure Init_directions
- If Temp$=" Four Directions "
- No_directions%=4
- Restore Info4
- Else
- Restore Info8
- No_directions%=8
- Endif
- ' **** Direction information for puzzle words ****
- Info8:
- Data 0,1, 1,1, 1,0, 1,-1, 0,-1, -1,-1, -1,0, -1,1
- Info4:
- Data 0,1,1,0,0,-1,-1,0
- ' **** ****
- Erase Ri()
- Erase Ci()
- Dim Ri(No_directions%),Ci(No_directions%)
- For J%=1 To No_directions%
- Read Ri(J%),Ci(J%) ! Read pairs of row/col increments for directions
- Next J%
- Return
- ' ******* PROCEDURE SORT_WORDS *******************************************
- Procedure Sort_words
- Print "Sorting the word list."
- For J%=1 To No_words%
- Words_unused(J%)=J%
- Next J%
- Repeat
- Sf!=False
- For J%=1 To No_words%-1
- If Len(Words$(Words_unused(J%)))<Len(Words$(Words_unused(J%+1)))
- Swap Words_unused(J%),Words_unused(J%+1) ! Swap words
- Sf!=True ! Set swap flag
- Endif
- Next J%
- Until Sf!=False
- Return
- ' ******* PROCEDURE SHUFFLE_CELL_NOS ***************************************
- Procedure Shuffle_cell_nos
- Print "Shuffling the cell numbers."
- For J%=1 To No_cells%
- Sequence(J%)=0
- Next J%
- For J%=1 To No_cells%
- Repeat
- Q=Int(Rnd*No_cells%)+1
- Until Sequence(Q)=0
- Sequence(Q)=J%
- Next J%
- Arrayfill Words_used(),-1 ! Put -1 in each element of Words_used()
- Return
- ' ******** PROCEDURE BUILD_PUZZLE ******************************************
- Procedure Build_puzzle
- If Wayflag!<>True
- Gosub Init_directions
- Endif
- Gosub Erasegrid
- Gosub Sort_words
- Gosub Shuffle_cell_nos
- ' **** Fill in the puzzle ****
- Print "Filling in the puzzle."
- Pass=1
- Cell_ptr=0
- Words_available=No_words%
- Durection=Int(Rnd*No_directions%)+1
- N1300:
- Print "Pass #";Pass;"...."
- ' **** Select the next cell ****
- N1310:
- Cell_ptr=Cell_ptr+1
- Nf=1
- Cp=Sequence(Cell_ptr)
- Cr=Int((Cp-1)/No_cols%)+1 ! Cell row
- Cc=Cp-(Cr-1)*No_cols% ! Cell column
- If Grid$(Cr,Cc)=Space$ Or (Pass=2 And Grid$(Cr,Cc)=Crosshatch$)
- Goto Check_cell_ptr
- Endif
- If Words_available=0
- Print "Used all words"
- Goto Random_fill
- Endif
- ' **** Select a word to put in puzzle ****
- Q=1
- Select_word:
- W=Words_unused(Q)
- W$=Words$(W)
- Wl=Len(W$)
- Dk=1
- N1460:
- Rx=Cr+(Wl-1)*Ri(Durection)
- Cx=Cc+(Wl-1)*Ci(Durection)
- If Rx<1 Or Rx>No_rows% Or Cx<1 Or Cx>No_cols%
- Goto Sel_direction ! Word does not fit
- Endif
- ' **** Determine if word conflicts with the grid's current letters ****
- Nf=0
- Pr=Cr
- Pc=Cc
- For L=1 To Wl
- T$=Grid$(Pr,Pc)
- If T$=Space$
- Goto N1580 ! Blank cell, word can't fit here in this direction
- Endif
- If T$=Crosshatch$
- Goto N1600 ! Cell contains #, this letter ok, now try next letter
- Endif
- L$=Mid$(W$,L,1) ! L$ = Next letter of word to try
- If L$=T$ ! If letter matches current cell contents
- Goto N1600
- Endif
- N1580:
- L=Wl ! Word won't fit in this direction
- Nf=1 ! Set Nofit flag
- N1600:
- Pr=Pr+Ri(Durection)
- Pc=Pc+Ci(Durection) ! Now try next cell/letter combination
- Next L
- If Nf=1
- Goto Sel_direction
- Endif
- ' **** No conflicts found, copy the word into the puzzle grid ****
- Pr=Cr
- Pc=Cc
- For L=1 To Wl
- Grid$(Pr,Pc)=Mid$(W$,L,1)
- Pr=Pr+Ri(Durection)
- Pc=Pc+Ci(Durection)
- Next L
- If Q<>Words_available
- For J%=Q To Words_available-1
- Words_unused(J%)=Words_unused(J%+1)
- Next J%
- Endif
- Dec Words_available
- Words_used(W)=(Durection-1)*No_cells%+Cp-1
- Inc Durection
- If Durection>No_directions%
- Durection=1
- Endif
- Goto Check_cell_ptr
- ' **** Select next direction until all directions tried ****
- Sel_direction:
- If Dk<>No_directions%
- Inc Dk
- Inc Durection
- If Durection>No_directions%
- Durection=1
- Endif
- Goto N1460
- Endif
- If Q<>Words_available
- Inc Q
- Goto Select_word
- Endif
- Check_cell_ptr:
- If Cell_ptr<>No_cells%
- Goto N1310
- Endif
- If Pass<>2
- Pass=2
- Cell_ptr=0
- Goto N1300
- Endif
- ' ******* Fill empty cells randomly to finish puzzle ********************
- Random_fill:
- Print "Filling in the empty cells at random"
- For Cr=1 To No_rows%
- For Cc=1 To No_cols%
- If Grid$(Cr,Cc)=Crosshatch$
- Grid$(Cr,Cc)=Chr$(Int(Rnd*26)+65)
- Endif
- Next Cc
- Next Cr
- ' **** Begin print sequence for completed puzzle ****
- Print "PUZZLE COMPLETED!"
- Print
- Build!=True ! Set flag to indicate puzzle now built
- Gosub Print_puzzle
- Ex_build:
- Return
- ' ******* PROCEDURE PRINT_PUZZLE *****************************************
- Procedure Print_puzzle
- Gosub Select_device ! Ask user to specify output device
- Cls
- Print #1,Tab(10);"FIND THE FOLLOWING HIDDEN WORDS IN THE PUZZLE:"
- Print #1
- Gosub Print_word_list
- Gosub Print_grid
- If Dv=1
- Print
- Print " < TO CONTINUE: CLICK MOUSE BUTTON, OR PRESS ANY KEY >"
- Repeat
- Button%=Mousek
- Key$=Inkey$
- Until (Button%=1 Or Button%=2) Or Key$<>""
- Endif
- Mess$="Print|hidden|word|directory?"
- Alert 2,Mess$,1,"Yes|No",D
- If D=1
- Gosub Print_hidden_dir
- Endif
- Gosub Close_device ! Close output print device
- Cls
- Ex_print_puz:
- Return
- ' ******* PROCEDURE PRINT_GRID *****************************************
- Procedure Print_grid
- Print #1
- Lmargin%=Int((80-(2*No_cols%))/2)
- For R%=1 To No_rows%
- Print #1,Tab(Lmargin%); ! Set left margin to center puzzle rows
- For C%=1 To No_cols%-1
- If Pr_flag$="pattern" And Grid$(R%,C%)<>Space$
- Print #1,"#";Space$;
- Else
- Print #1,Grid$(R%,C%);Space$;
- Endif
- Next C%
- If Pr_flag$="pattern" And Grid$(R%,C%)<>Space$
- Print #1,"#"
- Else
- Print #1;Grid$(R%,C%)
- Endif
- Next R%
- Return
- ' ******* PROCEDURE PRINT_WORD_LIST ************************************
- Procedure Print_word_list
- Counter%=1
- For J%=1 To No_words%
- If Counter%<=3
- Print #1,Tab(10+((Counter%-1)*16));Words$(J%);
- Inc Counter%
- Else
- Print #1,Tab(10+((Counter%-1)*16));Words$(J%)
- Counter%=1
- Endif
- Next J%
- Print #1
- Print #1
- Return
- ' ******* PROCEDURE PRINT_HIDDEN_DIR ***********************************
- Procedure Print_hidden_dir
- Cls
- Print #1
- Print #1
- Print #1
- Print #1
- Print #1,Tab(10);"The hidden words are:"
- Print #1
- Print #1,Tab(10);"Word";Tab(30);"Row";Tab(36);"Col.";Tab(42);"Direction"
- For J%=1 To No_words%
- If Words_used(J%)<>-1
- Durection=Int(Words_used(J%)/No_cells%)+1
- Cp=Words_used(J%)-(Durection-1)*No_cells%+1
- Cr=Int((Cp-1)/No_cols%)+1
- Cc=Cp-(Cr-1)*No_cols%
- If No_directions%=4 And Durection<>1
- Durection=Durection*2-1 ! Adjust hidden dir printout for 4 dirs only
- Endif
- Print #1,Tab(10);Words$(J%);Tab(30);Cr;Tab(36);Cc;Tab(42);Durection
- Endif
- Next J%
- Print #1
- Print #1,Tab(10);"Direction 6 7 8"
- Print #1,Tab(10);"Key: \ | /"
- Print #1,Tab(10);" 5 --+-- 1"
- Print #1,Tab(10);" / | \"
- Print #1,Tab(10);" 4 3 2"
- If Dv=1
- Print
- Print " < TO CONTINUE: CLICK MOUSE BUTTON, OR PRESS ANY KEY >"
- Repeat
- K=Mousek
- K$=Inkey$
- Until (K=1 Or K=2) Or K$<>""
- Endif
- Cls
- Return
- ' ******* PROCEDURE SELECT_DEVICE ******************************************
- Procedure Select_device
- Mess$="Print where?"
- Alert 2,Mess$,2,"Screen|Printer",Dv
- If Dv=1
- Open "o",#1,"con:"
- Else
- Open "o",#1,"prn:"
- Endif
- Return
- ' ******* PROCEDURE CLOSE_DEVICE *******************************************
- Procedure Close_device
- Close #1
- Return
- ' ******* PROCEDURE NEW_PATTERN ******************************************
- Procedure New_pattern
- Erase Grid$() ! Erase all arrays
- Erase Sequence() ! to prepare for reuse
- Erase Ri()
- Erase Ci()
- Pattern!=False ! Set flag to indicate no pattern at present
- Wayflag!=False ! Set flag to indicate directions need reinitialize
- Gosub Create_pattern
- Return
- ' ******* PROCEDURE CHG_PATTERN *****************************************
- Procedure Chg_pattern
- Gosub Erasegrid
- Build!=False ! Force puzzle rebuild when pattern changes
- Lastcol%=No_cols%*2
- For Y1%=1 To No_rows%
- For X1%=1 To Lastcol% Step 2
- X%=Int(X1%/2)+1 ! Column position in array
- If X1%<>Lastcol%
- Print At(X1%,Y1%);Grid$(Y1%,X%);
- Else
- Print At(X1%,Y1%);Grid$(Y1%,X%)
- Endif
- Next X1%
- Next Y1%
- If No_rows%<22 ! Horizontal line below pattern
- Line 0,(No_rows%*8*Rez%)+1,Lastcol%*8,(No_rows%*8*Rez%)+1
- Endif
- Deffill 1,2,1
- If Lastcol%<79 ! Vertical line to right of pattern
- Line Lastcol%*8,0,Lastcol%*8,(No_rows%*8*Rez%)+1
- Endif
- If Lastcol%<79
- Fill Lastcol%*8+2,(Lastrow%*8*Rez%)+2 ! Darken area outside pattern
- Endif
- M$="Use mouse to modify pattern|-Left button erases #|-Right button fills #|-EXIT by pressing both buttons"
- Alert 0,M$,1,"OK",Button%
- Do
- Mouse X%,Y%,Button%
- Exit If Button%=3
- X1%=Int(X%/8)+1 ! Column position on screen ie) double spaced etc.
- Y1%=Int(Y%/(8*Rez%))+1 ! Row position on screen
- X%=Int(X1%/2)+1 ! Column position in array
- If X%>No_cols% Or Y1%>No_rows%
- Goto Ignore
- Endif
- If Odd(X1%)
- If Button%=2
- Print At(X1%,Y1%);"#";
- Grid$(Y1%,X%)="#"
- Endif
- If Button%=1
- Print At(X1%,Y1%);" ";
- Grid$(Y1%,X%)=" "
- Endif
- Endif
- Ignore:
- Loop
- Cls
- Return
- ' ******* PROCEDURE PRINT_PATTERN ******************************************
- Procedure Print_pattern
- Pr_flag$="pattern"
- Gosub Select_device
- Cls
- Gosub Print_grid
- If Dv=1
- Print
- Print " < TO CONTINUE: CLICK MOUSE BUTTON, OR PRESS ANY KEY >"
- Repeat
- Button%=Mousek
- Key$=Inkey$
- Until (Button%=1 Or Button%=2) Or Key$<>""
- Endif
- Gosub Close_device
- Cls
- Pr_flag$=""
- Ex_print:
- Return
- ' ******* PROCEDURE SAVE_PATTERN ********************************************
- Procedure Save_pattern
- Cls
- Fileselect Dir$(0)+"\*.PAT","",Temp$
- If Temp$<>""
- If Right$(Temp$,4)<>".PAT"
- Temp$=Temp$+".PAT"
- Endif
- Open "O",#1,Temp$
- Write #1,No_rows%,No_cols%,No_cells%
- For R%=1 To No_rows%
- For C%=1 To No_cols%
- Write #1,Grid$(R%,C%)
- Next C%
- Next R%
- Print At(20,6);Temp$;" has been saved on disk"
- Close #1
- Pause 100
- Cls
- Endif
- Ex_save:
- Return
- ' ******* PROCEDURE LOAD_PATTERN *****************************************
- Procedure Load_pattern
- Cls
- Fileselect Dir$(0)+"\*.PAT","",Temp$
- If Temp$<>""
- Open "I",#1,Temp$
- Input #1,No_rows%,No_cols%,No_cells%
- If Pattern!=True
- Erase Grid$()
- Erase Sequence()
- Endif
- Dim Grid$(No_rows%,No_cols%),Sequence(No_cells%) ! Dimension grid
- For R%=1 To No_rows%
- For C%=1 To No_cols%
- Input #1,Grid$(R%,C%)
- Next C%
- Next R%
- Pattern!=True
- Close #1
- Print At(20,6);Temp$;" pattern loaded"
- Pause 100
- If Wayflag!=True
- Erase Ri() ! Allow loaded pattern to be used for
- Erase Ci() ! either 4 or 8 directions
- Wayflag!=False
- Endif
- Cls
- Endif
- Return
- ' ****** PROCEDURE BUILD_MENU_BAR *******************************************
- Procedure Build_menu_bar
- For I%=0 To 60
- Read Strip$(I%)
- Exit If Strip$(I%)="***"
- Next I%
- Strip$(I%)=""
- Strip$(I%+1)=""
- Menu Strip$()
- Return
- ' ***** PROCEDURE DRAW_TITLE **************************************************
- Procedure Draw_title
- Defline 1,3 ! Draw frame around entire screen
- Box 2,0*Rez%,637,(200*Rez%)-1
- Deffill 1,2,23 ! Draw rounded filled box in centre screen
- Prbox 20,55*Rez%,620,155*Rez%
- If Rez%=1
- Deffill 2,2,16
- Else
- Deffill 1,2,16
- Endif
- Pcircle 180,105*Rez%,100 ! Draw filled circles centre screen
- If Rez%=1
- Deffill 3,2,16
- Endif
- Pcircle 460,105*Rez%,100
- If Rez%=1
- Deffill 2,2,8
- Else
- Deffill 1,2,8
- Endif
- Prbox 20,163*Rez%,620,173*Rez% ! Draw solid fill rounded box
- If Rez%=1 ! Colour screen
- Deftext 1,5,0,6
- Else
- Deftext 1,5,0,13 ! Monochrome screen
- Endif
- Text 260,45*Rez%,"By Earl Toman"
- Text 260,190*Rez%,"Press any key..."
- Count=1
- Colour%=1
- Repeat
- Deftext Colour%,13,0,32
- Text 160,30*Rez%,"Word Puzzle Designer"
- Pause 5
- Colour%=Colour%+1
- If (Rez%=2) And (Colour%=2)
- Colour%=0
- Else
- If Rez%=1 And Colour%=4
- Colour%=1
- Endif
- Endif
- Exit If Inkey$<>""
- Count=Count+1
- Until Count=20
- ' ***** RESTORE DEFAULTS ****************************************************
- If Rez%=1
- Deftext 1,0,0,6
- Else
- Deftext 1,0,0,13
- Endif
- Defline 1,1,0,0
- Return
- ' ***** DATA FOR MAIN MENU BAR **********************************************
- Main_menu_bar_data:
- Data "Desk "," Word Puzzle Designer "
- Data --------------------
- Data 1,2,3,4,5,6,""
- Data "Pattern "," Create "," Edit "," New "," Print "," Save "," Load ",""
- Data "Wordlist "," New Wordlist "," Print Wordlist "," Add Words "," Edit Wordlist "," Save Wordlist "," Load Wordlist ",""
- Data "Options "," Four Directions "," Eight Directions ",""
- Data "Puzzle "," Build Puzzle "," Reprint Puzzle ",""
- Data "Done "," Quit ",""
- Data ***
- ' ***** DATA FOR EDIT MENU BAR **********************************************
- Ed_menu_bar_data:
- Data "Desk "," Word Puzzle Designer "
- Data --------------------
- Data 1,2,3,4,5,6,""
- Data "Return "," Back to Main Menu ",""
- Data ***
-